#ifndef _BOARD_CONFIG_H_
#define _BOARD_CONFIG_H_

#include <driver/gpio.h>

#define AUDIO_INPUT_SAMPLE_RATE  16000
#define AUDIO_OUTPUT_SAMPLE_RATE 24000

// If using Duplex I2S mode, comment the line below
#define AUDIO_I2S_METHOD_SIMPLEX

#ifdef AUDIO_I2S_METHOD_SIMPLEX

// 修改音频引脚以避免与摄像头引脚冲突
// 注意：ESP32-CAM上可用引脚非常有限，使用确认可用的引脚
#define AUDIO_I2S_MIC_GPIO_WS   GPIO_NUM_12  // D12 - 可用
#define AUDIO_I2S_MIC_GPIO_SCK  GPIO_NUM_13  // D13 - 可用
#define AUDIO_I2S_MIC_GPIO_DIN  GPIO_NUM_2   // GPIO 2 - 尝试使用
#define AUDIO_I2S_SPK_GPIO_DOUT GPIO_NUM_14  // D14 - 可用
#define AUDIO_I2S_SPK_GPIO_BCLK GPIO_NUM_15  // D15 - 可用
#define AUDIO_I2S_SPK_GPIO_LRCK GPIO_NUM_16  // D16 - 可用

#else

#define AUDIO_I2S_GPIO_WS GPIO_NUM_34
#define AUDIO_I2S_GPIO_BCLK GPIO_NUM_35
#define AUDIO_I2S_GPIO_DIN  GPIO_NUM_32
#define AUDIO_I2S_GPIO_DOUT GPIO_NUM_25

#endif


#define BUILTIN_LED_GPIO        GPIO_NUM_4    // D4
#define BOOT_BUTTON_GPIO        GPIO_NUM_0    // D0
#define TOUCH_BUTTON_GPIO       GPIO_NUM_NC
#define VOLUME_UP_BUTTON_GPIO   GPIO_NUM_NC
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_NC

// Camera Config - ESP32-CAM (AI-Thinker) standard pinout
// 保持摄像头引脚不变，但注意与音频引脚的复用问题
#define CAMERA_PIN_PWDN     GPIO_NUM_32  // D32
#define CAMERA_PIN_RESET    GPIO_NUM_NC  // -1
#define CAMERA_PIN_XCLK     GPIO_NUM_0   // D0
#define CAMERA_PIN_SIOD     GPIO_NUM_26  // D26
#define CAMERA_PIN_SIOC     GPIO_NUM_27  // D27
#define CAMERA_PIN_D7       GPIO_NUM_35  // D35
#define CAMERA_PIN_D6       GPIO_NUM_34  // D34
#define CAMERA_PIN_D5       GPIO_NUM_39  // D39
#define CAMERA_PIN_D4       GPIO_NUM_36  // D36
#define CAMERA_PIN_D3       GPIO_NUM_21  // D21
#define CAMERA_PIN_D2       GPIO_NUM_19  // D19
#define CAMERA_PIN_D1       GPIO_NUM_18  // D18
#define CAMERA_PIN_D0       GPIO_NUM_5   // D5
#define CAMERA_PIN_VSYNC    GPIO_NUM_25  // D25
#define CAMERA_PIN_HREF     GPIO_NUM_23  // D23
#define CAMERA_PIN_PCLK     GPIO_NUM_22  // D22
#define XCLK_FREQ_HZ        20000000

// Note: ESP32-CAM module doesn't have built-in LCD. The following definitions are optional for external LCD.
// If LCD is not needed, these definitions can be ignored
#define DISPLAY_BACKLIGHT_PIN GPIO_NUM_NC
#define DISPLAY_MOSI_PIN      GPIO_NUM_NC
#define DISPLAY_CLK_PIN       GPIO_NUM_NC
#define DISPLAY_DC_PIN        GPIO_NUM_NC
#define DISPLAY_RST_PIN       GPIO_NUM_NC
#define DISPLAY_CS_PIN        GPIO_NUM_NC

#ifdef CONFIG_LCD_ST7789_240X320
#define LCD_TYPE_ST7789_SERIAL
#define DISPLAY_WIDTH   240
#define DISPLAY_HEIGHT  320
#define DISPLAY_MIRROR_X false
#define DISPLAY_MIRROR_Y false
#define DISPLAY_SWAP_XY false
#define DISPLAY_INVERT_COLOR    true
#define DISPLAY_RGB_ORDER  LCD_RGB_ELEMENT_ORDER_RGB
#define DISPLAY_OFFSET_X  0
#define DISPLAY_OFFSET_Y  0
#define DISPLAY_BACKLIGHT_OUTPUT_INVERT false
#define DISPLAY_SPI_MODE 0
#endif

#endif // _BOARD_CONFIG_H_